package cn.shuto.liferay.plugin.chart.service.model.impl;

import cn.shuto.liferay.plugin.chart.service.model.Option;
import cn.shuto.liferay.plugin.chart.service.model.OptionModel;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.lar.StagedModelType;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the Option service. Represents a row in the &quot;echarts_Option&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link cn.shuto.liferay.plugin.chart.service.model.OptionModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link OptionImpl}.
 * </p>
 *
 * @author shixw
 * @see OptionImpl
 * @see cn.shuto.liferay.plugin.chart.service.model.Option
 * @see cn.shuto.liferay.plugin.chart.service.model.OptionModel
 * @generated
 */
public class OptionModelImpl extends BaseModelImpl<Option>
    implements OptionModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a option model instance should use the {@link cn.shuto.liferay.plugin.chart.service.model.Option} interface instead.
     */
    public static final String TABLE_NAME = "echarts_Option";
    public static final Object[][] TABLE_COLUMNS = {
            { "uuid_", Types.VARCHAR },
            { "optionId", Types.BIGINT },
            { "groupId", Types.BIGINT },
            { "companyId", Types.BIGINT },
            { "userId", Types.BIGINT },
            { "userName", Types.VARCHAR },
            { "createDate", Types.TIMESTAMP },
            { "modifiedDate", Types.TIMESTAMP },
            { "name", Types.VARCHAR },
            { "description", Types.VARCHAR },
            { "templateParamValue", Types.CLOB },
            { "chartTemplateId", Types.BIGINT },
            { "dataSourceId", Types.BIGINT },
            { "dataSql", Types.CLOB }
        };
    public static final String TABLE_SQL_CREATE = "create table echarts_Option (uuid_ VARCHAR(75) null,optionId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name VARCHAR(75) null,description VARCHAR(75) null,templateParamValue TEXT null,chartTemplateId LONG,dataSourceId LONG,dataSql TEXT null)";
    public static final String TABLE_SQL_DROP = "drop table echarts_Option";
    public static final String ORDER_BY_JPQL = " ORDER BY option.createDate DESC";
    public static final String ORDER_BY_SQL = " ORDER BY echarts_Option.createDate DESC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.cn.shuto.liferay.plugin.chart.service.model.Option"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.cn.shuto.liferay.plugin.chart.service.model.Option"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.cn.shuto.liferay.plugin.chart.service.model.Option"),
            true);
    public static long COMPANYID_COLUMN_BITMASK = 1L;
    public static long GROUPID_COLUMN_BITMASK = 2L;
    public static long UUID_COLUMN_BITMASK = 4L;
    public static long CREATEDATE_COLUMN_BITMASK = 8L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.cn.shuto.liferay.plugin.chart.service.model.Option"));
    private static ClassLoader _classLoader = Option.class.getClassLoader();
    private static Class<?>[] _escapedModelInterfaces = new Class[] { Option.class };
    private String _uuid;
    private String _originalUuid;
    private long _optionId;
    private long _groupId;
    private long _originalGroupId;
    private boolean _setOriginalGroupId;
    private long _companyId;
    private long _originalCompanyId;
    private boolean _setOriginalCompanyId;
    private long _userId;
    private String _userUuid;
    private String _userName;
    private Date _createDate;
    private Date _modifiedDate;
    private String _name;
    private String _description;
    private String _templateParamValue;
    private long _chartTemplateId;
    private long _dataSourceId;
    private String _dataSql;
    private long _columnBitmask;
    private Option _escapedModel;

    public OptionModelImpl() {
    }

    @Override
    public long getPrimaryKey() {
        return _optionId;
    }

    @Override
    public void setPrimaryKey(long primaryKey) {
        setOptionId(primaryKey);
    }

    @Override
    public Serializable getPrimaryKeyObj() {
        return _optionId;
    }

    @Override
    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    @Override
    public Class<?> getModelClass() {
        return Option.class;
    }

    @Override
    public String getModelClassName() {
        return Option.class.getName();
    }

    @Override
    public Map<String, Object> getModelAttributes() {
        Map<String, Object> attributes = new HashMap<String, Object>();

        attributes.put("uuid", getUuid());
        attributes.put("optionId", getOptionId());
        attributes.put("groupId", getGroupId());
        attributes.put("companyId", getCompanyId());
        attributes.put("userId", getUserId());
        attributes.put("userName", getUserName());
        attributes.put("createDate", getCreateDate());
        attributes.put("modifiedDate", getModifiedDate());
        attributes.put("name", getName());
        attributes.put("description", getDescription());
        attributes.put("templateParamValue", getTemplateParamValue());
        attributes.put("chartTemplateId", getChartTemplateId());
        attributes.put("dataSourceId", getDataSourceId());
        attributes.put("dataSql", getDataSql());

        return attributes;
    }

    @Override
    public void setModelAttributes(Map<String, Object> attributes) {
        String uuid = (String) attributes.get("uuid");

        if (uuid != null) {
            setUuid(uuid);
        }

        Long optionId = (Long) attributes.get("optionId");

        if (optionId != null) {
            setOptionId(optionId);
        }

        Long groupId = (Long) attributes.get("groupId");

        if (groupId != null) {
            setGroupId(groupId);
        }

        Long companyId = (Long) attributes.get("companyId");

        if (companyId != null) {
            setCompanyId(companyId);
        }

        Long userId = (Long) attributes.get("userId");

        if (userId != null) {
            setUserId(userId);
        }

        String userName = (String) attributes.get("userName");

        if (userName != null) {
            setUserName(userName);
        }

        Date createDate = (Date) attributes.get("createDate");

        if (createDate != null) {
            setCreateDate(createDate);
        }

        Date modifiedDate = (Date) attributes.get("modifiedDate");

        if (modifiedDate != null) {
            setModifiedDate(modifiedDate);
        }

        String name = (String) attributes.get("name");

        if (name != null) {
            setName(name);
        }

        String description = (String) attributes.get("description");

        if (description != null) {
            setDescription(description);
        }

        String templateParamValue = (String) attributes.get(
                "templateParamValue");

        if (templateParamValue != null) {
            setTemplateParamValue(templateParamValue);
        }

        Long chartTemplateId = (Long) attributes.get("chartTemplateId");

        if (chartTemplateId != null) {
            setChartTemplateId(chartTemplateId);
        }

        Long dataSourceId = (Long) attributes.get("dataSourceId");

        if (dataSourceId != null) {
            setDataSourceId(dataSourceId);
        }

        String dataSql = (String) attributes.get("dataSql");

        if (dataSql != null) {
            setDataSql(dataSql);
        }
    }

    @Override
    public String getUuid() {
        if (_uuid == null) {
            return StringPool.BLANK;
        } else {
            return _uuid;
        }
    }

    @Override
    public void setUuid(String uuid) {
        if (_originalUuid == null) {
            _originalUuid = _uuid;
        }

        _uuid = uuid;
    }

    public String getOriginalUuid() {
        return GetterUtil.getString(_originalUuid);
    }

    @Override
    public long getOptionId() {
        return _optionId;
    }

    @Override
    public void setOptionId(long optionId) {
        _optionId = optionId;
    }

    @Override
    public long getGroupId() {
        return _groupId;
    }

    @Override
    public void setGroupId(long groupId) {
        _columnBitmask |= GROUPID_COLUMN_BITMASK;

        if (!_setOriginalGroupId) {
            _setOriginalGroupId = true;

            _originalGroupId = _groupId;
        }

        _groupId = groupId;
    }

    public long getOriginalGroupId() {
        return _originalGroupId;
    }

    @Override
    public long getCompanyId() {
        return _companyId;
    }

    @Override
    public void setCompanyId(long companyId) {
        _columnBitmask |= COMPANYID_COLUMN_BITMASK;

        if (!_setOriginalCompanyId) {
            _setOriginalCompanyId = true;

            _originalCompanyId = _companyId;
        }

        _companyId = companyId;
    }

    public long getOriginalCompanyId() {
        return _originalCompanyId;
    }

    @Override
    public long getUserId() {
        return _userId;
    }

    @Override
    public void setUserId(long userId) {
        _userId = userId;
    }

    @Override
    public String getUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
    }

    @Override
    public void setUserUuid(String userUuid) {
        _userUuid = userUuid;
    }

    @Override
    public String getUserName() {
        if (_userName == null) {
            return StringPool.BLANK;
        } else {
            return _userName;
        }
    }

    @Override
    public void setUserName(String userName) {
        _userName = userName;
    }

    @Override
    public Date getCreateDate() {
        return _createDate;
    }

    @Override
    public void setCreateDate(Date createDate) {
        _columnBitmask = -1L;

        _createDate = createDate;
    }

    @Override
    public Date getModifiedDate() {
        return _modifiedDate;
    }

    @Override
    public void setModifiedDate(Date modifiedDate) {
        _modifiedDate = modifiedDate;
    }

    @Override
    public String getName() {
        if (_name == null) {
            return StringPool.BLANK;
        } else {
            return _name;
        }
    }

    @Override
    public void setName(String name) {
        _name = name;
    }

    @Override
    public String getDescription() {
        if (_description == null) {
            return StringPool.BLANK;
        } else {
            return _description;
        }
    }

    @Override
    public void setDescription(String description) {
        _description = description;
    }

    @Override
    public String getTemplateParamValue() {
        if (_templateParamValue == null) {
            return StringPool.BLANK;
        } else {
            return _templateParamValue;
        }
    }

    @Override
    public void setTemplateParamValue(String templateParamValue) {
        _templateParamValue = templateParamValue;
    }

    @Override
    public long getChartTemplateId() {
        return _chartTemplateId;
    }

    @Override
    public void setChartTemplateId(long chartTemplateId) {
        _chartTemplateId = chartTemplateId;
    }

    @Override
    public long getDataSourceId() {
        return _dataSourceId;
    }

    @Override
    public void setDataSourceId(long dataSourceId) {
        _dataSourceId = dataSourceId;
    }

    @Override
    public String getDataSql() {
        if (_dataSql == null) {
            return StringPool.BLANK;
        } else {
            return _dataSql;
        }
    }

    @Override
    public void setDataSql(String dataSql) {
        _dataSql = dataSql;
    }

    @Override
    public StagedModelType getStagedModelType() {
        return new StagedModelType(PortalUtil.getClassNameId(
                Option.class.getName()));
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
            Option.class.getName(), getPrimaryKey());
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        ExpandoBridge expandoBridge = getExpandoBridge();

        expandoBridge.setAttributes(serviceContext);
    }

    @Override
    public Option toEscapedModel() {
        if (_escapedModel == null) {
            _escapedModel = (Option) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
        }

        return _escapedModel;
    }

    @Override
    public Object clone() {
        OptionImpl optionImpl = new OptionImpl();

        optionImpl.setUuid(getUuid());
        optionImpl.setOptionId(getOptionId());
        optionImpl.setGroupId(getGroupId());
        optionImpl.setCompanyId(getCompanyId());
        optionImpl.setUserId(getUserId());
        optionImpl.setUserName(getUserName());
        optionImpl.setCreateDate(getCreateDate());
        optionImpl.setModifiedDate(getModifiedDate());
        optionImpl.setName(getName());
        optionImpl.setDescription(getDescription());
        optionImpl.setTemplateParamValue(getTemplateParamValue());
        optionImpl.setChartTemplateId(getChartTemplateId());
        optionImpl.setDataSourceId(getDataSourceId());
        optionImpl.setDataSql(getDataSql());

        optionImpl.resetOriginalValues();

        return optionImpl;
    }

    @Override
    public int compareTo(Option option) {
        int value = 0;

        value = DateUtil.compareTo(getCreateDate(), option.getCreateDate());

        value = value * -1;

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof Option)) {
            return false;
        }

        Option option = (Option) obj;

        long primaryKey = option.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        OptionModelImpl optionModelImpl = this;

        optionModelImpl._originalUuid = optionModelImpl._uuid;

        optionModelImpl._originalGroupId = optionModelImpl._groupId;

        optionModelImpl._setOriginalGroupId = false;

        optionModelImpl._originalCompanyId = optionModelImpl._companyId;

        optionModelImpl._setOriginalCompanyId = false;

        optionModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<Option> toCacheModel() {
        OptionCacheModel optionCacheModel = new OptionCacheModel();

        optionCacheModel.uuid = getUuid();

        String uuid = optionCacheModel.uuid;

        if ((uuid != null) && (uuid.length() == 0)) {
            optionCacheModel.uuid = null;
        }

        optionCacheModel.optionId = getOptionId();

        optionCacheModel.groupId = getGroupId();

        optionCacheModel.companyId = getCompanyId();

        optionCacheModel.userId = getUserId();

        optionCacheModel.userName = getUserName();

        String userName = optionCacheModel.userName;

        if ((userName != null) && (userName.length() == 0)) {
            optionCacheModel.userName = null;
        }

        Date createDate = getCreateDate();

        if (createDate != null) {
            optionCacheModel.createDate = createDate.getTime();
        } else {
            optionCacheModel.createDate = Long.MIN_VALUE;
        }

        Date modifiedDate = getModifiedDate();

        if (modifiedDate != null) {
            optionCacheModel.modifiedDate = modifiedDate.getTime();
        } else {
            optionCacheModel.modifiedDate = Long.MIN_VALUE;
        }

        optionCacheModel.name = getName();

        String name = optionCacheModel.name;

        if ((name != null) && (name.length() == 0)) {
            optionCacheModel.name = null;
        }

        optionCacheModel.description = getDescription();

        String description = optionCacheModel.description;

        if ((description != null) && (description.length() == 0)) {
            optionCacheModel.description = null;
        }

        optionCacheModel.templateParamValue = getTemplateParamValue();

        String templateParamValue = optionCacheModel.templateParamValue;

        if ((templateParamValue != null) && (templateParamValue.length() == 0)) {
            optionCacheModel.templateParamValue = null;
        }

        optionCacheModel.chartTemplateId = getChartTemplateId();

        optionCacheModel.dataSourceId = getDataSourceId();

        optionCacheModel.dataSql = getDataSql();

        String dataSql = optionCacheModel.dataSql;

        if ((dataSql != null) && (dataSql.length() == 0)) {
            optionCacheModel.dataSql = null;
        }

        return optionCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(29);

        sb.append("{uuid=");
        sb.append(getUuid());
        sb.append(", optionId=");
        sb.append(getOptionId());
        sb.append(", groupId=");
        sb.append(getGroupId());
        sb.append(", companyId=");
        sb.append(getCompanyId());
        sb.append(", userId=");
        sb.append(getUserId());
        sb.append(", userName=");
        sb.append(getUserName());
        sb.append(", createDate=");
        sb.append(getCreateDate());
        sb.append(", modifiedDate=");
        sb.append(getModifiedDate());
        sb.append(", name=");
        sb.append(getName());
        sb.append(", description=");
        sb.append(getDescription());
        sb.append(", templateParamValue=");
        sb.append(getTemplateParamValue());
        sb.append(", chartTemplateId=");
        sb.append(getChartTemplateId());
        sb.append(", dataSourceId=");
        sb.append(getDataSourceId());
        sb.append(", dataSql=");
        sb.append(getDataSql());
        sb.append("}");

        return sb.toString();
    }

    @Override
    public String toXmlString() {
        StringBundler sb = new StringBundler(46);

        sb.append("<model><model-name>");
        sb.append("cn.shuto.liferay.plugin.chart.service.model.Option");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>uuid</column-name><column-value><![CDATA[");
        sb.append(getUuid());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>optionId</column-name><column-value><![CDATA[");
        sb.append(getOptionId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>groupId</column-name><column-value><![CDATA[");
        sb.append(getGroupId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>companyId</column-name><column-value><![CDATA[");
        sb.append(getCompanyId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userId</column-name><column-value><![CDATA[");
        sb.append(getUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userName</column-name><column-value><![CDATA[");
        sb.append(getUserName());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>createDate</column-name><column-value><![CDATA[");
        sb.append(getCreateDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
        sb.append(getModifiedDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>name</column-name><column-value><![CDATA[");
        sb.append(getName());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>description</column-name><column-value><![CDATA[");
        sb.append(getDescription());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>templateParamValue</column-name><column-value><![CDATA[");
        sb.append(getTemplateParamValue());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>chartTemplateId</column-name><column-value><![CDATA[");
        sb.append(getChartTemplateId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>dataSourceId</column-name><column-value><![CDATA[");
        sb.append(getDataSourceId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>dataSql</column-name><column-value><![CDATA[");
        sb.append(getDataSql());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
